package com.bestv.search.common.service.impl;

import com.bestv.search.common.dao.SeriesDao;
import com.bestv.search.common.dataSource.DataSourceKey;
import com.bestv.search.common.model.Series;
import com.bestv.search.common.service.SeriesManager;

import java.util.List;

public class SeriesManagerImpl implements SeriesManager {

    private SeriesDao seriesDao;

    public SeriesDao getSeriesDao() {
        return seriesDao;
    }

    public void setSeriesDao(SeriesDao seriesDao) {
        this.seriesDao = seriesDao;
    }

    @Override
    public List<Series> getSeriesByCode(DataSourceKey key, String code) {
        return seriesDao.getProgramByCode(code);
    }

    @Override
    public void saveSeriesList(DataSourceKey key, List<Series> list) {
        seriesDao.saveObjectList(list);
    }

    @Override
    public void saveOrUpdate(DataSourceKey key, Series series) {
        seriesDao.saveOrUpdate(series);
    }

    @Override
    public void saveOrUpdate(DataSourceKey key, List<Series> seriesList) {
        if (seriesList != null && seriesList.size() > 0) {
            for (Series s : seriesList) {
                seriesDao.saveOrUpdate(s);
            }
        }
    }

    @Override
    public Series get(DataSourceKey key, long id) {
        return seriesDao.get(id);
    }
}
